package com.code.exam.mapper;

import com.code.exam.dto.UserRegisterDTO;
import com.code.exam.entity.Admin;
import com.code.exam.entity.User;
import org.apache.ibatis.annotations.*;


@Mapper
public interface UserMapper {

    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User getByUsername(String username);

    /**
     * 注册新用户
     * @param user
     */
    @Insert("insert into user (id,username,password,email)" + "values (#{id},#{username},#{password},#{email})")
    void register(User user);


    /**
     * 根据Id查询用户
     * @param Id
     * @return
     */
    @Select("select * from user where Id = #{Id}")
    User getById(Long Id);


    /**
     * 修改密码
     * @param newPassword
     */

    @Update("update user set password = #{password} where id = #{id}")
    void changepassword(@Param("password") String newPassword, @Param("id") Long userid);
}
